/**
 * PHOSIDE: PHosphorylation Site IDentification Engine.
 * Copyright 2009 Digital Biology Lab, University of Missouri.
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version. <p/> This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more
 * details.
 */

package phoside.ui.task;

import cytoscape.task.Task;
import cytoscape.task.ui.JTaskConfig;
import cytoscape.task.util.TaskManager;

import java.awt.Container;

/**
 *
 * @author gjj
 */
public final class TaskUtil {

    public static void execute(Task task) {
        execute(task, (JTaskConfig)null);
    }

    public static void execute(Task task, Container container) {
        execute(task, null, container);
    }

    public static void execute(Task task, JTaskConfig config) {
        execute(task, config, phoside.Phoside.getDesktop());
    }

    public static void execute(Task task, JTaskConfig config, Container container) {
        if (task==null)
            return;

        if (config==null) {
            config = new JTaskConfig();
            config.setOwner(container);
            config.displayCloseButton(true);
            config.displayCancelButton(false);
            config.displayStatus(true);
            config.setAutoDispose(true);
            config.setMillisToPopup(100);
        }

        TaskManager.executeTask(task, config);
    }
}
